package com.tarena.sentinel.demo01.service;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.stereotype.Service;

@Service
public class HelloService {
    @SentinelResource(value="resource02",blockHandler = "degradeHandler")
    public String sayHi(String name) {
        try {
            Thread.sleep(51);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "hello ["+name+"],sentinel welcome";
    }
    public String degradeHandler(String name, BlockException e) {
        return "sayHi资源被熔断了";
    }
}
